<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>搜索测试后台-批量添加关键字</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="${request.contextPath}/css/style.css">
	<script type="text/javascript" src="${request.contextPath}/js/jquery-1.6.1.min.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/main.js"></script>
	
	<script type="text/javascript">
	var pageInfo = {
		cp : 1,
		pp : 20
	};
	
	function listUnhandle(n) {
		n = n || 1;
		var _url = 'tunhandleList?cp=' + n + '&pp=' + pageInfo.pp;
		var len = 0;
		jQuery.ajax({
			url : _url,
			type : 'GET',
			success : function(json) {
				var h = '<table style="margin:auto;">' +
						'<tr style="background-color:#bbbbbb;font-weight:bold;">' +
	  					'	<td width="300">关键字</td>' +
	  					'	<td width="80">操作</td>' +
						'</tr>';
				if(json != null || json.length > 5) {
					pageInfo.cp = n;
					var obj = eval(json);
					len = obj.length;
					for(var i = 0; i < len; i ++) {
						var o = obj[i];
						var id = o.id;
						h += '<tr id="'+id+'">' +
							'	<td class="td1">' + o.key + '</td>' +
							'	<td class="td7"><a href="javascript:void(0);" onclick="deleteKeys(\''+id+'\');">删除</a></td>' +
							'</tr>';
					}
				}else{
					h += '<tr><td colspan="7">没有更多数据</td></tr>';
				}
				h += '</table>'
				$('#listUnhandle').html(h);
				$('#pageNum').html(getNextPage(pageInfo.cp, pageInfo.pp, len, 'listUnhandle'));
			}
		});
	}
	$(function(){
	});
	function t(o) {
		$("#filePath,#filePathHidden").val($(o).val());
	}
	function getNextPage(cp, pp, len, func) {
		var h = '';
		if(cp > 1) {
			h += '<a href="javascript:void(0);" onclick="'+func+'('+(cp - 1)+');">上一页</a>&nbsp;&nbsp;&nbsp;';
		}
		if(len >= pp){
			h += '<a href="javascript:void(0);" onclick="'+func+'('+(cp + 1)+');">下一页</a>&nbsp;&nbsp;&nbsp;';
		}
		h += '<a href="index">完成</a>';
		return h;
	}
	</script>
  </head>
  
  <body>
  	<div style="margin:10px auto 10px auto;width:100%;text-align:center;">
  		<h2>批量添加关键字</h2>
  	</div>
  	
  	<div class="mainDiv" style="">
  		<form id="fileForm" action="tdoBacthAdd" method="post" enctype="multipart/form-data">
  			<input type="text" value="" id="filePathHidden" readOnly="readOnly" size="40" />
  			<input type="hidden" value="" name="filePath" id="filePath" size="40" />
  			<input type="file" name="keyWords" onchange="t(this);" id="keyWords" />
  			
  			<input type="submit" value="查看或添加"  />
  			<a href="testIndex" class="link_">首页</a>
			<a href="tsingleAdd" class="link_">添加关键字</a>
  		</form>
  	</div>
  	
  	<div class="mainDiv" id="listUnhandle" style="text-align:center;">
	  	<#if keys?exists>
  			<table style="margin:auto;">
	  		<tr style="background-color:#bbbbbb;font-weight:bold;">
	  			<td width="300">关键字</td>
	  			<td width="80">操作</td>
	  		</tr>
		  	<#list keys as k>
		  		<tr id="${k.id}">
		  			<td>${k.key}</td>
		  			<td><a href="javascript:void(0);" onclick="deleteKeys('${k.id}');">删除</a></td>
		  		</tr>
		  	</#list>
	  		</table>
	  	</#if>
  	</div>
  	<div class="mainDiv" id="pageNum" style="padding-top:5px;">
	  	<#if keys?exists>
		  	<a href="javascript:void(0);" onclick="listUnhandle(2);">下一页</a>
	  		<a href="testIndex">完成</a>
	  	</#if>
  	</div>
  </body>
</html>
